<template>
  <div class="xtx-bread-item">
      <template v-if="to">
          <RouterLink :to="to"><slot/></RouterLink>
      </template>
      <template v-else>
          <span><slot /></span>
      </template>
    <!-- 分割符 逻辑渲染 -->
    <template v-if="separator">
        <i>{{separator}}</i>
    </template>
    <template v-else>
    <i class="iconfont icon-angle-right"></i>
    </template>
  </div>
</template>

<script>
import { inject } from 'vue'
export default {
  name: 'XtxBreadItem',
  props: {
    to: {
      type: String
    }
  },
  setup () {
    const separator = inject('separator')
    return {
      separator
    }
  }
}
</script>
<style lang="less" scoped>
  .xtx-bread-item {
    // 最后一个i隐藏
    &:nth-last-of-type(1) {
      i {
        display: none;
      }
    }
      i {
    font-size: 12px;
    margin-left: 5px;
    margin-right: 5px;
    line-height: 22px;
  }
  }
</style>
